 <?php 
 if ($this->session->userdata('id') > 0) {
	 
	if($upproduct->num_rows()>0){
		foreach($upproduct->result() as $rows){
			
	?>
                    
                    
                    
                    
<h4 class="d_h4" style="width:92%;">Update your product </h4><p style="color:#42C8D1">Please fill all <font color="red">*</font> feilds required !!!</p>
<p>&nbsp;</p>
<div class="col col_13">

    <div id="contact_form">
        <?php
        if (validation_errors() != "") {
            ?>
            <span id="error" style="background: none repeat scroll 0 0 #42C8D1;
                  color: red;
                  float: left;
                  line-height: 23px;
                  padding: 3px;
                  width: 539px;
                  border-radius: 3px;
                  ">
                <a href="<?php echo site_url('pages/user_add_products'); ?>">
                    <img class="error" style="float:right; cursor:pointer;" src="<?php echo site_url(); ?>admin/img/close.gif" />
                </a>
                <?php
                echo validation_errors();
                ?>
            </span>

            <?php
        }

        if ($this->uri->segment(3) == 'success') {
            ?>
            <span id="error" style="background: none repeat scroll 0 0 #42C8D1;
                  color: white;
                  float: left;
                  line-height: 23px;
                  padding: 3px;
                  width: 539px;
                  border-radius: 3px;
                  ">Register successfull go to  <a style="color:white" href="<?php echo site_url('pages/news'); ?>"> LOGIN</a> !!</span>
                  <?php
              }

              echo '<br /><br />';
			  ?>
			  
			  <a href="<?php echo site_url('pages/user_sel_up_product/'.$this->uri->segment(3).'/chang_pro'); ?>">
					<?php
                    $image_properties = array(
                        'src' => 'assets/uploads/thumbs/thumb_' . $rows->pro_img,
                        'alt' => $rows->pro_name,
                        'class' => 'post_images',
                        'width' => '80',
                        'height' => '70',
                        'title' => 'Click to change image',
                        'rel' => 'lightbox',
                    );
                    echo img($image_properties);
                    ?>
                </a>
                <?php 
                if($this->uri->segment(4)=='chang_pro'){
				  echo '<div style="float:left;">';
				   echo form_open_multipart('pages/change_product');
				   $upload = array(
                  		'name' => 'userfile',
						'placeholder' => 'Product upload....',
						'value' => set_value('userfile'),
						'type' => 'file',
						'size' => '20'
              		);
				   $getoldimg = array(
                  		'name' => 'getoldimg',
						'type' => 'hidden',
						'value' => $rows->pro_img
              		);
				?>
                	
					<?php echo form_input($upload); ?>
                    <?php echo form_input($getoldimg); ?>
                    <div class="cleaner h10"></div>
                    <input type="submit" value="Change now" id="submit" name="btn_upload" class="submit_btn float_l" />
                    <a href="<?php echo site_url('pages/user_sel_up_product/'.$this->uri->segment(3)); ?>"><input type="button" value="Reset" id="reset" name="reset" class="submit_btn float_r" /></a>
                    
                    <?php
                        echo form_close();
				}
                    ?>
                    <div class="cleaner h10"></div>
              <?php
              echo form_open_multipart('pages/user_sel_up_product');

              $pro_name = array(
                  'name' => 'pro_name',
                  'type' => 'text',
                  'placeholder' => 'Your products name...',
                  'id' => 'author',
                  'required' => '',
                  'class' => 'required input_field',
                  'autofocus' => '',
                  'value' => $rows->pro_name
              );
			  $pro_id = array(
                  'name' => 'getpro_id',
                  'type' => 'hidden',
                  'value' => $rows->pro_id
              );
			  
			  $pro_img = array(
                  'name' => 'getimg',
                  'type' => 'hidden',
                  'value' => $rows->pro_img
              );
			  
			  
              $cate = array(
                  $rows->pro_cate_id => $rows->pro_cate_id,
				  '1' => 'Computer',
                  '2' => 'Phone'
                  
              );
              $type = array(
                  $rows->pro_type => $rows->pro_type,
                  'new' => 'New',
                  'secondhand' => 'Second Hand'
              );
              $statu = array(
                  $rows->pro_statu_id => $rows->pro_statu_id,
                  '1' => 'Publish',
                  '0' => 'Unpublish'
              );
              $desc = array(
                  'name' => 'pro_desc',
                  'type' => 'textarea',
                  'placeholder' => 'Your description ...',
                  'cols' => '15',
                  'required' => '',
                  'rows' => '20',
                  'value' => $rows->pro_description
              );
              $price = array(
                  'name' => 'pro_price',
                  'type' => 'text',
                  'placeholder' => 'Your address...',
                  'id' => 'author',
                  'required' => '',
                  'class' => 'required input_field',
                  'value' => $rows->pro_price
              );
			 

            
              ?>


        <label for="author">Products name()<font color="red">*</font>:</label>
              <?php echo form_input($pro_name); ?>
              <?php echo form_input($pro_id); ?>
              <?php echo form_input($pro_img); ?>
        <div class="cleaner h10"></div>

        <label for="author">Categories():</label>
        <?php echo form_dropdown('pro_cate', $cate); ?>
        <div class="cleaner h10"></div>
        <label for="author">Type():</label>
<?php echo form_dropdown('pro_type', $type); ?>
        <div class="cleaner h10"></div>

        <label for="author">Status()<font color="red">*</font>:</label> 
        <?php echo form_dropdown('pro_statu', $statu); ?>
        <div class="cleaner h10"></div>

        <label for="author">Price($)<font color="red">*</font>:</label> 
        <?php echo form_input($price); ?>
        <div class="cleaner h10"></div>

        <label for="email">Description()<font color="red">*</font>:</label> 
        <?php echo form_textarea($desc); ?>
        <div class="cleaner h10"></div>
        
        <br />
        <input type="submit" value="Save" id="submit" name="btn_upload" class="submit_btn float_l" />
        <input type="reset" value="Reset" id="reset" name="reset" class="submit_btn float_r" />
         <br />

<?php
	echo form_close();
?>


    </div>
</div>
	<?php
            }
        }
	}else{
		redirect(site_url());
	}
    ?>